package com.example.l.zcq1;

import android.hardware.Sensor;
import android.os.Parcel;
import android.support.v4.app.Fragment;
import android.os.Parcelable;
public class sensor{
    //名字
    private String sensorName;
    //单位
    private String dataUnit;
    //值
    private double data;
    //获取名字的方法
    public String getSensorName(){return sensorName;}
    //设置名字的方法
    public void setSensorName(String sensorName) {this.sensorName=sensorName;}
    //获取单位的值
    public String getDataUnit(){return dataUnit;}
    public void setDataUnit(String dataUnit){this.dataUnit=dataUnit;}

    public double getData() {return data; }

    public void setData(double data) { this.data = data; }
    //实例化此对象是就可以传入相关数据
    public sensor (String sensorName,String dataUnit,double data){
        this.sensorName=sensorName;
        this.dataUnit=dataUnit;
        this.data=data;
    }
    //同容器的方式将数据传入到实体当中
    protected sensor(Parcel in){
        sensorName=in.readString();
        dataUnit=in.readString();
        data=in.readDouble();
    }
    public static final Parcelable.Creator<sensor> CREATOR=new Parcelable.Creator<sensor>() {
        @Override
        public sensor createFromParcel(Parcel source) {
            return new sensor(source);
        }

        @Override
        public sensor[] newArray(int size) {
            return new sensor[size]; }
    };
}
